/**
 * 
 */
package com.effectiv.gooruda.rest.api.controller;


import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.servlet.ModelAndView;


/**
 * @author Dhrubo
 * 
 */
@Controller
@Slf4j
public class DocsController {
	

	
	@RequestMapping(value = "/")
	public ModelAndView docs(@RequestParam("a") String app, ModelAndView mv){
		log.info("Loading documentation for app = {}", app);
		
		//TODO - Make this configurable
		String url = "http://localhost:8080/"+ app + "/apidocs";
		
		/*RestTemplate restClient = new RestTemplate();
		ResponseEntity<RestApiDoc>  response = restClient.getForEntity(url, RestApiDoc.class);
		
		RestApiDoc doc = null;
		
		if(response.getStatusCode().value() == HttpServletResponse.SC_OK){
			doc = response.getBody();
		}
		
		log.info("Loading documentation = {}", doc);
		
		model.addAttribute("doc", doc);
		
		*/
		
		mv.addObject("url", url);
		mv.setViewName("jsondoc");
		
		return mv;
	}
	
}
